package nina.yiyou.attendance.s10merge.compute.wage

import java.time.LocalDate
import java.time.LocalDateTime

class IsProbationChecker {

  IsProbationChecker(String employeeId, LocalDate attendDate, Map<String, Map> basicMap) {
    _employeeId = employeeId
    _attendDate = attendDate
    _basicMap = basicMap
  }

  boolean check() {
    Map<String, Object> employeeMap = _basicMap[_employeeId]
    assert employeeMap, "花名册找不到员工：${_employeeId}"

    LocalDateTime fullStart = checkAndGetFullStart(employeeMap)
    if (!fullStart) {
      return true
    }

    return _attendDate.isBefore(fullStart.toLocalDate())
  }

  private LocalDateTime checkAndGetFullStart(Map<String, Object> employeeMap) {
    def fullStart = employeeMap['转正日期']
    assert fullStart instanceof LocalDateTime
    return fullStart
  }

  private final String _employeeId
  private final LocalDate _attendDate

  private final Map<String, Map> _basicMap
}
